﻿using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections;
using System.Configuration;
using System.Net;
using System.IO;
namespace ProcessesSMS
{
    /// <summary>
    /// Summary description for CKVN.
    /// </summary>
    public class TC
    {

        private string connStringViettel = ConfigurationSettings.AppSettings["SMSConnStrViettel"].ToString();
        private SMS_MO WMO;
        private SMS_MT WMT;
        //private SMS_LIST WML;
        ArrayList arr = new ArrayList();
        public TC(SMS_MO MO)
        {
            WMO = MO;
        }

        public TC()
        {
        }
        public void run()
        {
            WMT = new SMS_MT(WMO);
            //string tmpMsg = WMO.Message.Substring(WMO.CommandCode.Length).Trim().Replace("  ", " ").Replace("  ", " ");
            //tmpMsg = tmpMsg.Replace("  ", " ").Trim().ToUpper();
            //string[] msg = tmpMsg.Split(new char[] { ' ' });
            string strReturnMsg = ConfigurationSettings.AppSettings["SMS_TC"].ToString(); // "7x62 xac nhan ban da tu choi nhan quang cao tu tong dai";//
            //if (strReturnMsg != "")
            //{
            InsertTC();
            WMT.AddMessage(WMO.UserID, strReturnMsg, SMS_ContentType.SMS_TEXT);
            WMT.MsgType = SMS_MsgType.SMS_TINHTIEN;
            WMT.Insert();
            //}
            return;
        }
        private int InsertTC()
        {
            string SQL = "insert into SMS_TC(MO_ID,UserID,RequestTime) values(@MO_ID,@UserID,@RequestTime)";
            SqlConnection conn = new SqlConnection(connStringViettel);
            conn.Open();
            SqlCommand oCommand = new SqlCommand(SQL, conn);
            oCommand.Parameters.Clear();
            oCommand.Parameters.AddWithValue("@MO_ID", WMO.MO_ID);
            oCommand.Parameters.AddWithValue("@UserID", WMO.UserID);
            oCommand.Parameters.AddWithValue("@RequestTime", WMO.RequestTime);
            oCommand.ExecuteNonQuery();
            conn.Close();
            conn.Dispose();
            return 1;
        }
    }
}
